//
//  PlayDetailControlView.swift
//  TimMusic
//
//  Created by nkl on 2024/10/12.
//

import Foundation
import UIKit
import TSVideoKit

class PlayDetailControlView : UIView {
    lazy var hStack : UIStackView = {
        let stack = UIStackView.hStack
        stack.distribution = .fillEqually
        return stack
    }()
    lazy var modelBtn : UIButton =  {
        let btn = UIButton()
        btn.setImage(UIImage.init(named: "ic_model"), for: .normal)
        return btn
    }()
    
    lazy var lastBtn : UIButton =  {
        let btn = UIButton()
        btn.setImage(UIImage.init(named: "ic_play_last"), for: .normal)
        return btn
    }()
    
    lazy var playBtn : PlayButtonView =  {
        let btn = PlayButtonView()
        return btn
    }()
    
    
    lazy var nextBtn : UIButton =  {
        let btn = UIButton()
        btn.setImage(UIImage.init(named: "ic_play_next"), for: .normal)
        return btn
    }()
    
    lazy var playlistBtn : UIButton =  {
        let btn = UIButton()
        btn.setImage(UIImage.init(named: "ic_playlist"), for: .normal)
        return btn
    }()
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        addChildren()
        makeConstraints()
    }
    

    
    func addChildren(){
        addSubview(hStack)
        hStack.addArrangedSubview(modelBtn)
        hStack.addArrangedSubview(lastBtn)
        hStack.addArrangedSubview(playBtn)
        hStack.addArrangedSubview(nextBtn)
        hStack.addArrangedSubview(playlistBtn)

    }
    
    func makeConstraints(){
        hStack.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}


extension LoopMode {
    var icon: String {
        switch self {
        case .cyclic:
            return "ic_cycle"
        case .random:
            return "ic_random"
        case .repeat:
            return "ic_single"
        }
    }
}
